﻿using System.Web;
using System.Web.Routing;
using System.Web.Compilation;
using System.Web.UI;

/// <summary>
/// Summary description for RouteHandler
/// </summary>
public class RouteHandler : IRouteHandler
{
    public RouteHandler()
    {

    }
    public RouteHandler(string virtualPath)
    {
        _virtualPath = virtualPath;
    }

    public IHttpHandler GetHttpHandler(RequestContext requestContext)
    {
        //var display = BuildManager.CreateInstanceFromVirtualPath(
        //                  _virtualPath, typeof (Page)) as IDisplay;
        //return display;
        foreach (var value in requestContext.RouteData.Values)
        {
            HttpContext.Current.Items[value.Key] = value.Value;

        }
        return (Page) BuildManager.CreateInstanceFromVirtualPath(_virtualPath, typeof (Page));


    }

    readonly string _virtualPath;
}
